--- @param extension Package
--- @param HY HY_Utility
--- @param U Utility
return function(extension, HY, U)
    local hy_sukuna_shinmyoumaru = General:new(extension, "hy_sukuna_shinmyoumaru", "chi_k", 3, 3, General.Female)
    local magical_mallet = fk.CreateSkill {
        name = "magical_mallet",
    }
    magical_mallet:addEffect("viewas", {
        mute_card = false,
        pattern = ".|.|.|.|.|basic",
        expand_pile = "magical_mallet_wish",
        interaction = function(self, player)
            local results = {}
            for _, name in ipairs(Fk:getAllCardNames("b")) do
                local card = Fk:cloneCard(name)
                table.insert(card.skillNames, magical_mallet.name)
                if Fk.currentResponsePattern == nil and player:canUse(card) then
                    table.insertIfNeed(results, name)
                elseif Fk.currentResponsePattern and Exppattern:Parse(Fk.currentResponsePattern):match(card) then
                    table.insertIfNeed(results, name)
                end
            end
            if #results == 0 then
                return
            end
            return UI.ComboBox { choices = results }
        end,
        card_filter = function(self, player, to_select, selected)
            if not self.interaction.data then
                return false
            end
            local card = Fk:cloneCard(self.interaction.data, Fk:getCardById(to_select).suit, Fk:getCardById(to_select)
                .number)
            if Fk.currentResponsePattern == nil then
                return #selected == 0 and player:getPileNameOfId(to_select) == "magical_mallet_wish" and not player:prohibitUse(card)
            elseif Fk.currentResponsePattern and Exppattern:Parse(Fk.currentResponsePattern):match(card) then
                return #selected == 0 and player:getPileNameOfId(to_select) == "magical_mallet_wish" and not player:prohibitResponse(card)
            end
        end,
        prompt = function(self, player, selected_cards, selected)
            return "magical_mallet_prompt"
        end,
        view_as = function(self, player, cards)
            if #cards ~= 1 or not self.interaction.data then return end
            local origin = Fk:getCardById(cards[1])
            local card = Fk:cloneCard(self.interaction.data, origin.suit, origin.number)
            card:addSubcard(origin)
            table.insertIfNeed(card.skillNames, magical_mallet.name)
            return card
        end,
        before_use = function(self, player, use)
            use.extra_data = use.extra_data or {}
            use.extra_data.bypass_distances = true
        end,
        enabled_at_play = function(self, player)
            return #player:getPile("magical_mallet_wish") > 0
        end,
        enabled_at_response = function(self, player, response)
            return #player:getPile("magical_mallet_wish") > 0
        end,
    })
    magical_mallet:addEffect(fk.EventPhaseStart, {
        anim_type = "drawcard",
        can_trigger = function(self, event, target, player)
            return player:hasSkill(magical_mallet.name) and player == target and player.phase == Player.Draw and #player:getPile("magical_mallet_wish") <= 2 and
                not (player:getMark("magical_mallet_disable-turn") > 0)
        end,
        on_use = function(self, event, target, player, data)
            local room = player.room
            local cards = room:askToGuanxing(player, {
                cards = room:getNCards(4),
                top_limit = { 0, 4 },
                bottom_limit = { 0, 4 },
                skill_name = magical_mallet.name,
                skip = true,
                area_names = { "magical_mallet_wish", "magical_mallet_get" }
            })
            for i = #cards.top, 1, -1 do
                player:addToPile("magical_mallet_wish", cards.top[i], true, magical_mallet.name)
            end
            room:obtainCard(player, cards.bottom, false, fk.ReasonPrey)
            data.phase_end = true
        end,
    })
    local wish_tax = fk.CreateSkill {
        name = "wish_tax",
    }
    wish_tax:addEffect(fk.EventPhaseStart, {
        anim_type = "negative",
        can_trigger = function(self, event, target, player)
            return player:hasSkill(wish_tax.name) and player == target and player.phase == Player.Start and player:isKongcheng()
        end,
        on_cost = Util.TrueFunc,
        on_use = function(self, event, target, player)
            local room = player.room
            if not player.dead then
                room:drawCards(player, 1, wish_tax.name)
            end
            room:addPlayerMark(player, "magical_mallet_disable-turn", 1)
            if #player:getPile("magical_mallet_wish") > 0 then
                room:moveCards({
                    from = player,
                    ids = player:getPile("magical_mallet_wish"),
                    toArea = Card.DiscardPile,
                    moveReason = fk.ReasonPutIntoDiscardPile,
                    skillName = wish_tax.name,
                })
            end
        end,
    })
    wish_tax:addEffect(fk.CardUseFinished, {
        anim_type = "negative",
        can_trigger = function(self, event, target, player, data)
            return player:hasSkill(wish_tax.name) and player == target and data.card.name == "peach" and table.contains(data.card.skillNames, magical_mallet.name)
        end,
        on_cost = Util.TrueFunc,
        on_use = function(self, event, target, player)
            if not player:isKongcheng() then
                player.room:askToDiscard(player, {
                    min_num = 1,
                    max_num = 1,
                    skill_name = wish_tax.name,
                    cancelable = false
                })
            end
        end
    })
    local bright_needle = fk.CreateSkill {
        name = "bright_needle",
    }
    bright_needle:addEffect(fk.TargetSpecified, {
        anim_type = "offensive",
        can_trigger = function(self, event, target, player, data)
            return target == player and player:hasSkill(bright_needle.name) and data.card and data.card.trueName == "slash" and data.card:isConverted()
        end,
        on_cost = Util.TrueFunc,
        on_use = function(self, event, target, player, data)
            data.to:addQinggangTag(data)
        end,
    })
    bright_needle:addEffect("targetmod", {
        bypass_distances = function(self, player, skill, card, to)
            if player:hasSkill(bright_needle.name) and card then
                return card.trueName == "slash" and (card:isConverted() or table.contains(card.skillNames, magical_mallet.name))
            end
        end
    })
    extension:loadSkillSkels { magical_mallet, wish_tax, bright_needle }
    hy_sukuna_shinmyoumaru:addSkills { "magical_mallet", "wish_tax", "bright_needle" }
    Fk:loadTranslationTable {
        ["hy_sukuna_shinmyoumaru"] = "少名针妙丸",
        ["#hy_sukuna_shinmyoumaru"] = "末代抗争者",
        ["illustrator:hy_sukuna_shinmyoumaru"] = "サニーサイド",
        ["designer:hy_sukuna_shinmyoumaru"] = "黑曜人形",
        ["cv:hy_sukuna_shinmyoumaru"] = "",

        ["magical_mallet"] = "小槌",
        [":magical_mallet"] = "摸牌阶段，若你的 “愿”不大于2，你可以放弃摸牌，改为观看牌堆顶四张牌，将任意张牌置于你的武将牌上，称为“愿”，然后获得其余的牌。你可以将“愿”当作任意基本牌使用或打出。",
        ["magical_mallet_wish"] = "愿",
        ["magical_mallet_get"] = "进入手牌",
        ["magical_mallet_prompt"] = "小槌：将一张“愿”当作任意基本牌使用或打出",

        ["wish_tax"] = "奢愿",
        [":wish_tax"] = "准备阶段，若你没有手牌，你摸一张牌并移去所有“愿”，本回合你不能发动“小槌”。在你将一张 “愿”当作【桃】使用结算结束后，你弃置一张手牌。",

        ["bright_needle"] = "辉针",
        [":bright_needle"] = "你的转化【杀】无视防具且无距离限制。",
    }
end
